﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MS.Internal.Mita.Foundation.Waiters;
using MS.Internal.Mita.Foundation;
using MS.Internal.Mita.Foundation.Controls;

namespace WordTestApp
{
    public class DSMTemplate
    {
        WindowOpenedWaiter wordWaiter = StartWord.wordWaiter;

        public DateTime TemplateMenuClickLetter()
        {
            UIObject word = wordWaiter.Source;

            try
            {
                var f = word.Descendants.Find(UICondition.Create("@Name='DSM Template System'"));
            }
            catch
            {
            }
            Button fileTemplateBtn = new Button(word.Descendants.Find(UICondition.Create("@Name='DSM Template System'")));
            fileTemplateBtn.Click();

            try
            {
                var f = word.Descendants.Find(UICondition.Create("@Name='DSM Letter'"));
            }
            catch
            {
            }
            Button letterBtn = new Button(word.Descendants.Find(UICondition.Create("@Name='DSM Letter'")));
            var startTime = DateTime.Now;
            letterBtn.Click();

            #region template letter windows
            WindowOpenedWaiter templateWinWaiter = new WindowOpenedWaiter(UICondition.CreateFromClassName("ThunderRT6FormDC"));
            templateWinWaiter.Wait();

            Window templateWin = new Window(templateWinWaiter.Source);
            templateWin.SetFocus();

            try
            {
                var f = word.Descendants.Find(UICondition.Create("@Name='Finish'"));
            }
            catch
            {
            }

            //区分大小写
            Button finishButton = new Button(templateWin.Descendants.Find(UICondition.Create("@Name='Finish'")));
            finishButton.Click();
            return startTime;
            #endregion

        }
    }
}
